{extend name="admin@index_layout"/}
{block name="main"}
<style type="text/css">
    .childrenBody {
        background: #fff;
    }
</style>
<!--<style type="text/css">-->
<!--    .layui-layer-page .layui-layer-content {-->
<!--        overflow: inherit;-->
<!--    }-->
<!--</style>-->
<div class="layui-card">
    <div class="layui-card-header">首页弹窗广告</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
    </div>
</div>

<script type="text/html" id="barTool">
    {if $userInfo['roleid']==1}
    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?id={{ d.id }}' data-title="编辑内容"
       data-full="true">编辑</a>
    <a href='{:url("del")}?id={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
    {/if}
</script>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="用|不用" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="picTpl">

    <img style="max-width:80px; max-height:30px;" src="{{d.img_url}}" data-image="{{d.title}}">

</script>


{/block}
{block name="script"}
<script>
    layui.use(['table', 'yznTable'], function () {
        // var table = layui.table,
        //     $ = layui.$,
        //     form = layui.form,
        //     table = layui.table,
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            add_url: "{:url('add')}",
            delete_url: "{:url('del',['catid'=>$catid])}",
            modify_url: '{:url("listorder",["catid"=>$catid])}',
        };
        table.render({
            init: init,
            id: 'currentTable',
            elem: '#currentTable',
            url: '{:url("index")}',
            // searchFormTpl:,
            toolbar: ['refresh',
                [{
                    text: '添加',
                    url: init.add_url,
                    method: 'open',
                    icon: 'iconfont icon-add',
                    class: 'layui-btn layui-btn-normal layui-btn-sm',
                    extend: 'data-full="true"',
                }],
            ],
            cols: [
                [
                    {type: 'checkbox', fixed: 'left'},
                    {field: 'id', width: 60, title: 'ID'},
                    {field: 'title', align: "center", title: '标题'},
                    {field: 'img_url', align: "center", title: '图片', templet: '#picTpl',search:false},
                    {field: 'status', align: "center", title: '是否开启', templet: '#statusTpl',search:false},
                    {field: 'start_time', align: "center", title: '开始时间',search:false},
                    {field: 'end_time', align: "center", title: '结束时间',search:false},
                    {fixed: 'right', width: 180, title: '操作', toolbar: '#barTool'}
                ]
            ],
            page: {}
        });
        yznTable.bindevent();
    });
</script>
{/block}